//
// Button groups
// --------------------------------------------------


// Make the div behave like a button
.btn-group {
  position: relative;
  display: inline-block;
  .ie7-inline-block();
  font-size: 0; // remove as part 1 of font-size inline-block hack
  vertical-align: middle; // match .btn alignment given font-size hack above
  white-space: nowrap; // prevent buttons from wrapping when in tight spaces (e.g., the table on the tests page)
  .ie7-restore-left-whitespace();
}

// Space out series of button groups
// .btn-group + .btn-group {
.btn-group /* fix for IE6 */ {
  margin-left: 5px;
}
.btn-group-first {
  /* fix for IE6 */
  margin-left: 0;
}

// Optional: Group multiple button groups together for a toolbar
.btn-toolbar {
  font-size: 0; // Hack to remove whitespace that results from using inline-block
  margin-top: @baseLineHeight / 2;
  margin-bottom: @baseLineHeight / 2;
  // .btn + .btn,
  // .btn-group + .btn,
  // .btn + .btn-group {
  .btn
  .btn-group /* fix for IE6 */ {
    margin-left: 5px;
  }
  .btn-first,
  .btn-group-first /* fix for IE6 */ {
    margin-left: 0;
  }
}

// Float them, remove border radius, then re-add to first and last elements
// .btn-group > .btn {
.btn-group .btn /* fix for IE6 */ {
  position: relative;
  .border-radius(0);
}
//.btn-group > .btn + .btn {
.btn-group .btn /* fix for IE6 */ {
  margin-left: -1px;
}
.btn-group .btn-first /* fix for IE6 */ {
  margin-left: 0;
}
// .btn-group > .btn,
// .btn-group > .dropdown-menu {
.btn-group .btn,
.btn-group .dropdown-menu /* fix for IE6 */ {
  font-size: @baseFontSize; // redeclare as part 2 of font-size inline-block hack
}
.btn-group .dropdown-menu /* fix for IE6 */ {
  .divider {
    _margin:5px 0 -5px;
  }
}

// Reset fonts for other sizes
// .btn-group > .btn-mini {
.btn-group .btn-mini /* fix for IE6 */ {
  font-size: 11px;
}
// .btn-group > .btn-small {
.btn-group .btn-small /* fix for IE6 */ {
  font-size: 12px;
}
// .btn-group > .btn-large {
.btn-group .btn-large /* fix for IE6 */ {
  font-size: 16px;
}

// Set corners individual because sometimes a single button can be in a .btn-group and we need :first-child and :last-child to both match
.btn-group > .btn:first-child {
  margin-left: 0;
     -webkit-border-top-left-radius: 4px;
         -moz-border-radius-topleft: 4px;
             border-top-left-radius: 4px;
  -webkit-border-bottom-left-radius: 4px;
      -moz-border-radius-bottomleft: 4px;
          border-bottom-left-radius: 4px;
}
// Need .dropdown-toggle since :last-child doesn't apply given a .dropdown-menu immediately after it
.btn-group > .btn:last-child,
.btn-group > .dropdown-toggle {
     -webkit-border-top-right-radius: 4px;
         -moz-border-radius-topright: 4px;
             border-top-right-radius: 4px;
  -webkit-border-bottom-right-radius: 4px;
      -moz-border-radius-bottomright: 4px;
          border-bottom-right-radius: 4px;
}
// Reset corners for large buttons
.btn-group > .btn.large:first-child {
  margin-left: 0;
     -webkit-border-top-left-radius: 6px;
         -moz-border-radius-topleft: 6px;
             border-top-left-radius: 6px;
  -webkit-border-bottom-left-radius: 6px;
      -moz-border-radius-bottomleft: 6px;
          border-bottom-left-radius: 6px;
}
.btn-group > .btn.large:last-child,
.btn-group > .large.dropdown-toggle {
     -webkit-border-top-right-radius: 6px;
         -moz-border-radius-topright: 6px;
             border-top-right-radius: 6px;
  -webkit-border-bottom-right-radius: 6px;
      -moz-border-radius-bottomright: 6px;
          border-bottom-right-radius: 6px;
}

// On hover/focus/active, bring the proper btn to front
.btn-group > .btn:hover,
.btn-group > .btn:focus,
.btn-group > .btn:active,
.btn-group > .btn.active {
  z-index: 2;
}

// On active and open, don't show outline
.btn-group .dropdown-toggle:active,
.btn-group.open .dropdown-toggle {
  outline: 0;
}



// Split button dropdowns
// ----------------------

// Give the line between buttons some depth
// .btn-group > .btn + .dropdown-toggle {
.btn-group .dropdown-toggle /* fix for IE6 */ {
  padding-left: 9px;
  padding-right: 9px;
  .box-shadow(~"inset 1px 0 0 rgba(255,255,255,.125), inset 0 1px 0 rgba(255,255,255,.2), 0 1px 2px rgba(0,0,0,.05)");
  // *padding-top: 5px;
  // *padding-bottom: 5px;
}
// .btn-group > .btn-mini + .dropdown-toggle {
.btn-group .btn-mini-dropdown-toggle /* fix for IE6 */ {
  padding-left: 7px;
  padding-right: 7px;
  // *padding-top: 4px;
  // *padding-bottom: 4px;
}
// .btn-group > .btn-small + .dropdown-toggle {
.btn-group .btn-small-dropdown-toggle /* fix for IE6 */ {
  // *padding-top: 5px;
  // *padding-bottom: 4px;
}
// .btn-group > .btn-large + .dropdown-toggle {
.btn-group .btn-large-dropdown-toggle /* fix for IE6 */ {
  padding-left: 17px;
  padding-right: 17px;
  // *padding-top: 12px;
  // *padding-bottom: 12px;
}

// .btn-group.open {
.btn-group-open {

  // The clickable button for toggling the menu
  // Remove the gradient and set the same inset shadow as the :active state
  .dropdown-toggle {
    background-image: none;
    .box-shadow(~"inset 0 2px 4px rgba(0,0,0,.15), 0 1px 2px rgba(0,0,0,.05)");
  }

  // Keep the hover's background when dropdown is open
  // .btn.dropdown-toggle {
  .btn-dropdown-toggle {
    background-color: @btnBackgroundHighlight;
  }
  // .btn-primary.dropdown-toggle,
  .btn-primary-dropdown-toggle {
    background-color: @btnPrimaryBackgroundHighlight;
  }
  // .btn-warning.dropdown-toggle {
  .btn-warning-dropdown-toggle {
    background-color: @btnWarningBackgroundHighlight;
  }
  // .btn-danger.dropdown-toggle {
  .btn-danger-dropdown-toggle {
    background-color: @btnDangerBackgroundHighlight;
  }
  // .btn-success.dropdown-toggle {
  .btn-success-dropdown-toggle {
    background-color: @btnSuccessBackgroundHighlight;
  }
  // .btn-info.dropdown-toggle {
  .btn-info-dropdown-toggle {
    background-color: @btnInfoBackgroundHighlight;
  }
  // .btn-inverse.dropdown-toggle {
  .btn-inverse-dropdown-toggle {
    background-color: @btnInverseBackgroundHighlight;
  }
}


// Reposition the caret
.btn .caret {
  margin-top: 8px;
  margin-left: 0;

  _display: inline;
  _zoom:1;
  _height: 8px;
  _vertical-align: middle;
}
.btn-mini .caret,
.btn-small .caret {
  _height: 10px;
}
// Carets in other button sizes
.btn-mini .caret,
.btn-small .caret,
.btn-large .caret {
  margin-top: 6px;
}
.btn-large .caret {
  border-left-width:  5px;
  border-right-width: 5px;
  border-top-width:   5px;

  _height: 9px;
}
// Upside down carets for .dropup
.dropup .btn-large .caret {
  border-bottom-width: 5px;
}



// Account for other colors
.btn-primary,
.btn-warning,
.btn-danger,
.btn-info,
.btn-success,
.btn-inverse {
  .caret {
    border-top-color: @white;
    border-bottom-color: @white;
  }
}


// Vertical button groups
// ----------------------

.btn-group-vertical {
  display: inline-block; // makes buttons only take up the width they need
  .ie7-inline-block();
}
.btn-group-vertical .btn {
  display: block;
  float: none;
  width: 100%;
  .border-radius(0);
}
.btn-group-vertical .btn + .btn {
  margin-left: 0;
  margin-top: -1px;
}
.btn-group-vertical .btn:first-child {
  .border-radius(4px 4px 0 0);
}
.btn-group-vertical .btn:last-child {
  .border-radius(0 0 4px 4px);
}
.btn-group-vertical .btn-large:first-child {
  .border-radius(6px 6px 0 0);
}
.btn-group-vertical .btn-large:last-child {
  .border-radius(0 0 6px 6px);
}
